package com.headingdata.d7_interface_demo;

import java.util.ArrayList;

public class StudentOperatorImp1 implements StudentOperator{
    @Override
    public void printAllStudentInfo(ArrayList<Student> students) {
        System.out.println("------------全班全部学生信息如下------------");
        for (int i = 0; i < students.size(); i++) {
            Student s = students.get(i);
            System.out.println("姓名：" + s.getName() + ",性别：" + s.getSex() + ",成绩：" + s.getScore());
        }
        System.out.println("==========================================");
    }

    @Override
    public void printAllStudentAverage(ArrayList<Student> students) {

        double totalScore = 0;
        for (int i = 0; i < students.size(); i++) {
            totalScore += students.get(i).getScore();
        }
        System.out.println("全本同学的平均成绩：" + totalScore/students.size());
    }
}
